package com.neutech.neusys.controller;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neusys.po.Department;
import com.neutech.neusys.service.FmedService;
import com.neutech.po.ExpenseClass;
import com.neutech.po.Fmeditem;
import com.neutech.vo.FmedVo;

@RestController
@RequestMapping("/his/sys")
public class FmedController {
	@Autowired
	private FmedService fmedService;
//	查询非药品收费项目 分页
//	根据名称查询非药品收费项目
	@RequestMapping(value="/selectfmed",method=RequestMethod.GET)
	public  FmedVo selectAll(@RequestParam Map<String,Object> map){

		return fmedService.selectAll(map);
	}
//	添加非药品收费项目
//	@param:fmed 项目信息
//	@return:添加成功还是失败，"success"/"error"
	@RequestMapping(value="/insertfmed",method=RequestMethod.POST)
	public String InsFmed(@RequestBody Fmeditem fmed){
		fmed.setCreationDate(new Date());
		int result = fmedService.InsFmed(fmed);
		if(result>0){
			return "成功";
		}else{
			return "失败";
		}
		
	}
//	添加前查询费用分类
	@RequestMapping(value="/selectexp",method=RequestMethod.POST)
	public @ResponseBody List<ExpenseClass> selectExp(){
		
		return fmedService.selectExp();
	}
//	添加前查询执行科室
	@RequestMapping(value="/selectdep",method=RequestMethod.POST)
	public @ResponseBody List<Department> selectdep(){
		
		return fmedService.selectdep();
	}
//	根据id修改非药品收费项目信息
	@RequestMapping(value="/updatefmed",method=RequestMethod.POST)
	public String updatefmed(@RequestBody Map<String,Object> fmed){
		int result = fmedService.updatefmed(fmed);
		if(result>0){
			return "成功";
		}else{
			return "失败";
		}
	}
//	根据id删除非药品收费项目
	@RequestMapping(value="/delById",method=RequestMethod.GET)
	public String delById(Fmeditem fmed){
		int result = fmedService.delById(fmed);
		if(result>0){
			return "成功";
		}else{
			return "失败";
		}
	}

}
